import { utils } from 'ym-design';
const { uuid } = utils;
interface ymFilePathKey {
  /**
   * @desc 内部规范
   * @default "default"
   */
  phone?: string;
  /**
   * @desc 内部规范
   * @default "Web"
   */
  system?: 'Android' | 'iOS' | 'Web' | 'WX' | 'Cloud';
  client?:
    | 'BumblebeeApp'
    | 'MegatronApp'
    | 'MegatronWeb'
    | 'Boss'
    | 'WX'
    | 'Cloud';
}

export function ymFilePathCreate({ client, phone, system }: ymFilePathKey) {
  return function filePathRules(file: File, path: string) {
    const ext = file.name.split('.').pop();
    const date = new Date();
    const YYYY = date.getFullYear() + '';
    const MM = `0${date.getMonth()}`.slice(-2);
    const DD = `0${date.getDate()}`.slice(-2);
    const HH = `0${date.getHours()}`.slice(-2);
    const mm = `0${date.getMinutes()}`.slice(-2);

    return `${client ?? 'MegatronWeb'}/${phone ?? 'default'}/${
      path ?? 'default'
    }/${YYYY + MM}/${YYYY + MM + DD}_${HH + mm}_${uuid()}_${
      system ?? 'Web'
    }.${ext}`;
  };
}
